package gspushmq.v1.app.subscribeapp.enumeration;

import org.apache.commons.lang3.StringUtils;

/**
 *
 * @Description 标签枚举
 * @Author chengsj
 * @Version 1.0
 *
 */
public enum TargetEnum {
    DEVICE("DEVICE","设备推送"),
    ACCOUNT("ACCOUNT","账户推送"),
    ALIAS("ALIAS","别名推送"),
    TAG("TAG","标签推送"),
    ALL("ALL","所有");

    String key;
    String value;

    TargetEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static String getNameByKey(String key){
        if (StringUtils.isBlank(key))
            return null;
        for (TargetEnum en : TargetEnum.values())
            if (en.getKey().equals(key))
                return en.getKey();
        return null;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static boolean contain(String code){
        if (StringUtils.isBlank(code))
            return false;
        for (TargetEnum en : TargetEnum.values())
            if (en.getKey().equalsIgnoreCase(code))
                return true;
        return false;
    }
}
